package com.indexingsystem.system.service.impl;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import com.github.pagehelper.PageHelper;
import com.indexingsystem.boss.admin.mapper.OperationsRelationsMapper;
import com.indexingsystem.boss.common.PagedResult;
import com.indexingsystem.boss.entity.OperationsRelations;
import com.indexingsystem.boss.utils.BeanUtils;
import com.indexingsystem.system.service.IOperationRelationsService;

/**
 * 功能操作权限服务类.
 * 
 * @author Administrator
 *
 */
@Service
public class OperationRelationsServiceImpl implements IOperationRelationsService {

	@Resource
	private OperationsRelationsMapper operationRelationsMapper;

	/**
	 * 通过功能操作id删除功能操作.
	 */
	@Override
	public int deleteByPrimaryKey(String relationsId) {
		return operationRelationsMapper.deleteByPrimaryKey(relationsId);
	}

	/**
	 * 新增功能操作关系.
	 */
	@Override
	public int insert(OperationsRelations record) {
		return operationRelationsMapper.insert(record);
	}

	/**
	 * 新增功能操作关系.
	 */
	@Override
	public int insertSelective(OperationsRelations record) {
		return operationRelationsMapper.insertSelective(record);
	}

	/**
	 * 通过功能操作id查询详情.
	 */
	@Override
	public OperationsRelations selectByPrimaryKey(String relationsId) {
		return operationRelationsMapper.selectByPrimaryKey(relationsId);
	}

	/**
	 * 带条件修改功能操作关系.
	 */
	@Override
	public int updateByPrimaryKeySelective(OperationsRelations record) {
		return operationRelationsMapper.updateByPrimaryKeySelective(record);
	}

	/**
	 * 全量修改功能操作关系.
	 */
	@Override
	public int updateByPrimaryKey(OperationsRelations record) {
		return operationRelationsMapper.updateByPrimaryKey(record);
	}

	/**
	 * 获取总记录数.
	 * 
	 * @return
	 */
	@Override
	public Integer getOperationsRelationsCount() {
		return operationRelationsMapper.getOperationsRelationsCount();
	}

	/**
	 * 分页查询功能操作权限列表.
	 * 
	 * @param functionId
	 * @param pageNo
	 * @param pageSize
	 * @return
	 */
	@Override
	public PagedResult<OperationsRelations> getOperationsRelationsList(String functionId, Integer pageNo,
			Integer pageSize) {
		pageNo = pageNo == null ? 1 : pageNo;
		pageSize = pageSize == null ? 10 : pageSize;
		// startPage是告诉拦截器说我要开始分页了。分页参数是这两个。
		PageHelper.startPage(pageNo, pageSize);
		return BeanUtils.toPagedResult(operationRelationsMapper.getOperationsRelationsList(functionId));
	}

	/**
	 * 通过功能id查询功能操作权限已关联列表总数量.
	 * 
	 * @param functionId
	 * @return
	 */
	@Override
	public Integer getOperationsRelationsByFunctionIdCount(String functionId) {
		return operationRelationsMapper.getOperationsRelationsByFunctionIdCount(functionId);
	}

	/**
	 * 获取功能操作权限关联列表
	 * 
	 * @param functionId
	 * @return
	 */
	@Override
	public List<OperationsRelations> getFunctionsOrOperationsRelationsList(String functionId) {
		return operationRelationsMapper.getOperationsRelationsList(functionId);
	}

	/**
	 * 批量删除功能操作权限关系.
	 * 
	 * @param functionId
	 * @return
	 */
	@Override
	public int deleteOperationsRelationsByIdBatch(List<String> relationsIdList) {
		return operationRelationsMapper.deleteOperationsRelationsByIdBatch(relationsIdList);
	}
	
	/**
	 * 批量新增功能操作权限关系.
	 * 
	 * @param operationsRelationsList
	 * @return
	 */
	@Override
	public int addOperationsRelationsBatch(List<OperationsRelations> list){
		return operationRelationsMapper.addOperationsRelationsBatch(list);
	}
}